var deviceone = require("deviceone");
var cacher = deviceone.sm("do_DataCache");


/**最后查看友事的时间key**/
var last_seen_topic_key = "lastseenusertopictime@qquan";

/**
 * 存取“最后查看友事的时间”
 */
module.exports.cacheLastTopicTime = function(){
	if(arguments.length==0){
		if(cacher.hasData(last_seen_topic_key)){
			var value = cacher.loadData(last_seen_topic_key);
			if(!value || value==null || value==="undefined"){
				return "" + new Date().getTime();
			}
			return value;
		}
    }
    if(arguments[0]===""){
    	cacher.removeData(last_seen_topic_key);
        return;
    }
    cacher.saveData(last_seen_topic_key,""+arguments[0]);
};

/**
 * model {"newUserTopicLogo":"xxxxx","newUserTopicNick":"jack"}
 */
var new_topic_tip_key = "new_usertopic_tip@qquan";
module.exports.cacheNewTopic = function(){
	if(arguments.length==0){
		if(cacher.hasData(new_topic_tip_key)){
			return cacher.loadData(new_topic_tip_key);
		}else{
			return null;
		}
    }
    if(arguments[0]==="" || arguments[0]=== null){
    	cacher.removeData(new_topic_tip_key);
        return;
    }
    cacher.saveData(new_topic_tip_key,arguments[0]);
};